//
//  ChatItemTipsView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/5/2.
//

import SwiftUI
import Kingfisher

struct ChatItemPatView: View {
    @ObservedObject var viewModel : ChatViewModel
    @State var item: ChatBean
    @State private var showDel = false //删除

    var body: some View {
        HStack{
            Text(item.getPatStr())
                .font(.system(size: 14))
                .foregroundStyle(.bgNormalText3)
                .padding(.horizontal, 10)
                .padding(.vertical, 10)
                .cornerRadius(10)
        }.frame(maxWidth: .infinity,alignment: .center)
            .contextMenu{
                Button("删除") {
                   showDel = true
                }
            }
            .alert("温馨提示",isPresented:$showDel) {
                Button("取消",role: .cancel){}
                Button("确定",role: .destructive) {
                    viewModel.delChat(bean: item)
                }
            } message: {
                Text("是否确定要删除")
            }
    }
    
}

#Preview {
    ChatItemPatView(viewModel: ChatViewModel(), item: ChatBean()).background(.bg)
}
